﻿using System;
using System.IO;

namespace NumericalSolution {
  class Program {
    static void Main(string[] args) {
      
      int numberOfNodes = 11;
      double deltaX = 1.0 / (numberOfNodes - 1);
      double deltaTime = 0.005;
      double endTime = 1.0;

      StreamWriter writer = File.CreateText("c:/nsworkspace/exact.txt");

      double[] u = new double[numberOfNodes];

      for (double currentTime = 0.0; currentTime <= endTime;
           currentTime += deltaTime) {

        u[0] = 0.0;
        for (int i = 1; i < u.Length - 1; i++) {
          u[i] = Math.Exp(-Math.PI * Math.PI * currentTime)
                       * Math.Sin(Math.PI * i * deltaX);
        }
        u[u.Length - 1] = 0.0;

        for (int i = 0; i < u.Length; i++) {
          writer.WriteLine(currentTime + " " + i * deltaX + " " + u[i]);
        }
        writer.WriteLine();

      }
      writer.Close();

    }
  }
}
